import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import 'package:webview_flutter/webview_flutter.dart';

import 'controller.dart';

class MerchantEnterInfomationPage extends StatefulWidget {
  const MerchantEnterInfomationPage({Key? key}) : super(key: key);

  @override
  State<MerchantEnterInfomationPage> createState() => _MerchantEnterInfomationPageState();
}

class _MerchantEnterInfomationPageState extends State<MerchantEnterInfomationPage> {
  final controller = Get.find<MerchantEnterInfomationController>();
  final state = Get.find<MerchantEnterInfomationController>().state;

  WebViewController webViewController = WebViewController()
    ..setJavaScriptMode(JavaScriptMode.unrestricted)
    ..setNavigationDelegate(
      NavigationDelegate(
        onProgress: (int progress) {
          // Update loading bar.
        },
        onPageStarted: (String url) {},
        onPageFinished: (String url) {},
        onWebResourceError: (WebResourceError error) {},
        onNavigationRequest: (NavigationRequest request) {
          if (request.url.startsWith('https://www.youtube.com/')) {
            return NavigationDecision.prevent;
          }
          return NavigationDecision.navigate;
        },
      ),
    )
    ..loadRequest(Uri.parse('https://m.hao123.com/?vit=h123&from=3w123'));

  @override
  Widget build(BuildContext context) {
    return MkPage(child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        backgroundColor: Colors.transparent,
        title: '商家入驻',
      ),
      body: WebViewWidget(controller:webViewController ,),
    ));
  }

  @override
  void dispose() {
    Get.delete<MerchantEnterInfomationController>();
    super.dispose();
  }
}